
#### Replicating the Main Results

To replicate the main results, run `replication.R`. This will generate all core output objects and save the console output to `output.txt`. You can then run `plotting.R` using these objects to reproduce the figures in the manuscript.

#### Appendix A

The code for Appendix A is in `additional_info.R`. The synthetic difference-in-differences (SDID) weights used in the event study are stored in the `Lambda` and `Omega` components of the SDID objects generated by `replication.R`.

#### Appendix B

The code for each alternative specification appears in a separate file:

* B.1: `backdating.R`
* B.2: `restricted.R`
* B.3: `reversal.R`
* B.4: `22and24.R`
* B.5: `mc.R`

#### Appendix C

The power analysis is implemented in `matrixcompletion_power.R` and `sdid_power.R`. To analyze different disaggregations of the data, modify the following lines before running:

*Data preparation:*

* All elections: `data = data[as.numeric(data$YEAR) %% 2 == 0, ]`
* Presidential elections: `data = data[as.numeric(data$YEAR) %% 4 == 0, ]`
* Midterm elections: `data = data[as.numeric(data$YEAR) %% 4 == 2, ]`

*Simulations:*

* All or presidential elections:
  `adopters2012 <- sample(remaining, 2)`
  `adopters2014 <- sample(remaining, 2)`
* Midterm elections:
  `adopters2012 <- sample(remaining, 3)`
  `adopters2014 <- sample(remaining, 3)`

For SDID you will also need to set `adopters2006` and `adopters2008` to `sample(remaining, 0)` to get the late adopter results or `adopters2012`, `adopters2014`, and `adopters2016` to `sample(remaining, 0)` to get the early adopter results. This is not necessary for matrix completion because the `fect` function already has the ability to disaggregate by adoption timing using the `est.group.att` component (row 1 for early adopters, 2 for late adopters).

In a comment next to each `sample(remaining, n)` is the correct number to sample when not disaggregating by adoption timing.

#### Files
`statelaws.csv` is a file containing the states and the years that they enforced voter ID laws from 1984-2020. `statelaws2024.csv` includes 2022 and 2024 laws.

`stateturnout.csv` is a file containing the states and their turnout from 1984-2020. `stateturnout2024.csv` includes 2022 and 2024 turnout data.



#### Data Sources

*Michael McDonald. 2024. “1980-2022 General Election Turnout Rates (v1.2).” https://election.lab.ufl.edu/dataset/1980-2022-general-election-turnout-rates-v1-2/*

*Michael McDonald. 2024. “Turnout Rates in the 2024 General Election (v0.1).” https://election.lab.ufl.edu/dataset/2024-general-election-turnout-rates-v0-3/*
